package com.ny.old;

import java.util.List;

public class TestList {
    public static void menu() {
        System.out.println("欢迎来到员工信息管理系统");
        System.out.println("0.退出系统");
        System.out.println("1.添加员工");
        System.out.println("2.查询所有的员工");
        System.out.println("3.根据员工姓名查询");
        System.out.println("4.删除员工信息");
        System.out.println("5.根据员工编号查询");
        System.out.println("6.根据员工编号修改年龄");
        System.out.println("请选择你需要进行的操作");
    }
    public void addEmp(List<Emp> list, Emp emp) {
        list.add(emp);
    }

    public void findAllEmp(List<Emp> list) {
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
    }

    public void findEmpName(List<Emp> list, String name) {
        for (int i = 0; i < list.size(); i++) {
            if (name.equals(list.get(i).getName())) {
                System.out.println(list.get(i));
            }
        }
    }

    public void deleteEmpNumber(List<Emp> list, String number) {
        for (int i = 0; i < list.size(); i++) {
            if (number.equals(list.get(i).getNumber())) {
                list.remove(i);
                System.out.println(list);
            }
        }
    }

    public Emp findEmpNumber(List<Emp> list, String number) {
        for (Emp emp : list) {
            if (number.equals(emp.getNumber())) {
                return emp;
            }
        }
        return null;
    }

    public void updateEmpAge(List<Emp> list, Emp emp) {
        for (int i = 0; i < list.size(); i++) {
            if (emp.getNumber().equals(list.get(i).getNumber())) {
                list.set(i, emp);
            }
        }
    }
}